package com.xc.controller;

import com.xc.model.dto.ResultDTO;
import com.xc.model.entity.AdEntity;
import com.xc.model.query.AdQuery;
import com.xc.service.AdService;
import com.xc.service.QuanService;
import com.xc.util.JSONCopy;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/home")//统一调用广告
public class AdController {
    @Autowired
    private AdService adService;
    @Value("${limit}")
    private String limit;

    @Autowired
    private QuanService quanService;
    @GetMapping("/ad")
    public ResultDTO getHomeAd(AdQuery adQuery) {
//        int limit = 3;//魔法字符：
//        adQuery.setLimit(limit);
//        System.out.println(limit);
//        String a="a";
//        a+="aa";
        for (int i = 0; i < 5; i++) {
            for (int j = 0; j <5 ; j++) {

            }
        }
        return adService.getHomeAd(JSONCopy.copy(adQuery, AdEntity.class));

    }
    @GetMapping("/quan")
   public ResultDTO getHomeQuan(){
        return quanService.getHomeQuan();
   }
}
